<?php
namespace App\Http\Controllers\ApiApp;

use App\Utility\Upload;
use Illuminate\Http\Request;

class UploadController extends BaseController
{
    /**
     * 文件上传
     */

    public function __construct()
    {
        parent::__construct();
    }

    /**
     * 上传
     */
    public function setUploadFile(Request $request)
    {
        $uid = $request->post('uid',0);
        $file = $request->file('file');
        if (!$file) {
            return $this->toAppJson(-2);
        }
        $resUpload = Upload::uploadFile($file);
        if ($resUpload['code']!=0) {
            return $this->toAppJson(-19);
        }
        $dataArr = array(
            'imgUrl' => $resUpload['data']['filePath'],
        );
        return $this->toAppJson(0, $dataArr);
    }
}
